// 引入Cout的UI组件
import CountUI from '../../components/Count'

// 引入connect用于连接UI组件与redux
import { connect } from 'react-redux'

import { createIncrementAction, createDecrementAction, createIncrementAsyncAction } from '../../redux/count_action'

// 创建Count容器组件
export default connect(
  state => ({ count: state }),
  /* 
   * mapDispatchToProps的一般写法
  dispatch => ({
    add: data => {
      // 通知redux执行加法
      dispatch(createIncrementAction(data))
    },
    minus: data => {
      dispatch(createDecrementAction(data))
    },
    addAsync: (data, interval) => {
      dispatch(createIncrementAsyncAction(data, interval))
    }
  })
   */

  // mapDispatchToProps的简写
  {
    add: createIncrementAction,
    minus: createDecrementAction,
    addAsync: createIncrementAsyncAction
  }
)(CountUI)
